<?php
class MHDEV_View_Helper_GetUserOnline extends Zend_View_Helper_Abstract
{
	/**
	 * @param boolean $show_guests: Show or show not guests in list
	 * 
	 * @return unknown_type
	 */
	public function GetUserOnline($show_guests = TRUE)
	{
		// vars
		$content	= array();
		
		// settings
		$settings	= Zend_Registry::get('settings');
		
		// lang
		$translate	= Zend_Registry::get('lang');
		
		// helper
		$date		= new MHDEV_View_Helper_Datetime();
		$author		= new MHDEV_View_Helper_GetAuthor();
		$url		= new Zend_View_Helper_Url();
		
		// db
		$user 		= new UserOnline();
		
		// query
		$check_member	= $user->fetchAll('user_uid > 0');
		$check_guests	= $user->fetchAll('user_uid = 0');
		
		if($check_member->count() > 0)
		{
			$content['member_count']	= $check_member->count();
			
			$select = $user->select()->setIntegrityCheck(false);
			$select->from(
					array('uo' => 'user_online')
				)
				->join(
					array('u' => 'user'), 'u.uid = uo.user_uid', array('username', 'role', 'group_uid')
				)
				->where('uo.user_uid > ?', 0)
				->order('u.username ASC');
				
			$content['member_res']		= $user->fetchAll($select);
		}
		else
		{
			$content['member_count']	= 0;
		}
		
		$content['online_time']	= $settings['online_count'];
		$content['total']		= ($check_member->count()+$check_guests->count());
		$content['guest_count']	= $check_guests->count();
		
		return $content;
	}
}